
package com.ruoyi.web.controller.system;


//import com.anji.plus.gaea.annotation.Permission;
//import com.anji.plus.gaea.annotation.log.GaeaAuditLog;
//import com.anji.plus.gaea.bean.ResponseBean;
//import com.ruoyi.system.domain.ReportDashboardObjectDto;
//import com.ruoyi.system.domain.ReportShareDto;
//import com.ruoyi.system.domain.ChartDto;
//import com.ruoyi.system.domain.vo.ResponseBean;
//import com.ruoyi.system.service.ReportDashboardService;
//import com.ruoyi.system.service.ReportShareService;
//import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.domain.ReportDashboardDto;
import com.ruoyi.system.domain.ReportDashboardObjectDto;
import com.ruoyi.system.domain.ReportDashboardWidget;
import com.ruoyi.system.service.ReportDashboardService;
import com.ruoyi.system.service.ReportDashboardWidgetService;
import com.sun.java.swing.plaf.windows.WindowsBorders;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
* @desc 大屏设计 controller
* @website https://gitee.com/anji-plus/gaea
* @author Raod
* @date 2021-04-12 14:52:21.761
**/
@RestController
//@Api(tags = "大屏设计管理")
@Api(value = "大屏设计管理",tags = "大屏设计管理")

//@Permission(code = "bigScreenManage", name = "大屏报表")
@RequestMapping("/reportDashboard")
public class ReportDashboardController {

    @Autowired
    private ReportDashboardService reportDashboardService;

    @Autowired
    private ReportDashboardWidgetService reportDashboardWidgetService;

    /**
     * 预览、查询大屏详情
     * @param reportCode
     * @return
     */
    @ApiOperation("预览、查询大屏详情")
    @GetMapping({"/{reportCode}"})
//    @Permission(code = "view", name = "查看大屏")
//    public ResponseBean detail(@PathVariable("reportCode") String reportCode) {
//        return ResponseBean.builder().data(reportDashboardService.getDetail(reportCode)).build();
//    }
    public Map detail(@PathVariable("reportCode") String reportCode) {
        ;

        Map result=new LinkedHashMap();
        result.put("args",null);
        result.put("code",200);
        result.put("message","操作成功");
//        ReportDashboardObjectDto reportDashboardObjectDto=new ReportDashboardObjectDto();
//        reportDashboardObjectDto.setReportCode("test5");
//        reportDashboardObjectDto.setWidgets(null);
//        ReportDashboardDto reportDashboardDto = new ReportDashboardDto();
//        reportDashboardDto.setBackgroundColor("");
//        reportDashboardDto.setBackgroundImage("https://ajreport.beliefteam.cn/file/download/db9d3ad3-6a1b-40c6-8f83-4d9539112791");
//        reportDashboardDto.setDeleteFlag(0);
//        reportDashboardDto.setEnableFlag(1);
//        reportDashboardDto.setHeight(1080L);
//        reportDashboardDto.setReportCode("");
//        reportDashboardDto.setReportCode("test5");
//        List<ReportDashboardWidget> list=new LinkedList<>();

//        reportDashboardObjectDto.setDashboard(reportDashboardDto);
        result.put("data",reportDashboardService.getDetail(reportCode));
        return result;
//        reportDashboardService.getDetail(reportCode);
    }


//    /**
//     * 保存大屏设计
//     * @param dto
//     * @return
//     */
//    @ApiOperation("保存大屏设计")
//
//    @PostMapping
//    @Permission(code = "design", name = "设计大屏")
//    @GaeaAuditLog(pageTitle = "新增")
//    public ResponseBean insert(@RequestBody ReportDashboardObjectDto dto) {
//        reportDashboardService.insertDashboard(dto);
//        return ResponseBean.builder().build();
//    }
//
//
//    /**
//     * 获取去单个图层数据
//     * @param dto
//     * @return
//     */
//    @ApiOperation("获取去单个图层数据")
//
//    @PostMapping("/getData")
//    @Permission(code = "view", name = "查看大屏")
//    public ResponseBean getData(@RequestBody ChartDto dto) {
//        return ResponseBean.builder().data(reportDashboardService.getChartData(dto)).build();
//    }
//
//
//    /**
//     * 导出大屏
//     * @param reportCode
//     * @return
//     */
//    @ApiOperation("导出大屏")
//
//    @GetMapping("/export")
//    @Permission(code = "export", name = "导出大屏")
//    public ResponseEntity<byte[]> exportDashboard(HttpServletRequest request, HttpServletResponse response,
//                                                  @RequestParam("reportCode") String reportCode, @RequestParam(value = "showDataSet",required = false, defaultValue = "1") Integer showDataSet) {
//        return reportDashboardService.exportDashboard(request, response, reportCode, showDataSet);
//    }
//
//    /**
//     * 导入大屏
//     * @param file  导入的zip文件
//     * @param reportCode
//     * @return
//     */
//    @ApiOperation("导入大屏")
//
//    @PostMapping("/import/{reportCode}")
//    @Permission(code = "import", name = "导入大屏")
//    public ResponseBean importDashboard(@RequestParam("file") MultipartFile file, @PathVariable("reportCode") String reportCode) {
//        reportDashboardService.importDashboard(file, reportCode);
//        return ResponseBean.builder().build();
//    }
//
//    @ApiOperation("分享")
//    @PostMapping("/share")
//    @GaeaAuditLog(pageTitle = "分享")
//    public ResponseBean share(@Validated @RequestBody ReportShareDto dto) {
////        return ResponseBean.builder().data(reportShareService.insertShare(dto)).build();
//        return null;
//    }

}
